package org.example.test;

import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
/*
基于注解的bean对象周期方法
 */
//    <bean id="javaBean" class="org.example.ioc_01.JavaBean" init-method="init" destroy-method="destroy" />
@Scope(scopeName = ConfigurableBeanFactory.SCOPE_SINGLETON)//单例
//@Scope(scopeName = ConfigurableBeanFactory.SCOPE_PROTOTYPE)//多例
@Component
public class JavaBean {
    @PostConstruct
    public void init(){
        System.out.println("init,annotation");
    }
    @PreDestroy
    public void destroy(){
        System.out.println("destroy,annotation");
    }
}
